<?php
/**
 * @function：多媒体信息管理接口
 * @Author: 倪银龙
 * @Mail niyinlong@126.com
 * @Date: 15-10-1
 * @Time: 上午9:00
 * @Blog: Http://www.thinkwechat.cn
 */
namespace wechat;
use wechat\accesstoken;
use wechat\curl;
/*
*素材管理
*临时素材管理和永久素材管理
*/
class send{
	/*
	*发送消息
	*/
	public function sendMessage($data){
		$tool = new accesstoken();
		$token = $tool->getAccessToken();
		$queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token='.$token;
                return curl::callWebServer($queryUrl, $data, 'POST', 1 , 0);
	}
        
        /*
         * 获取用户信息
         */
        public function getUserInfo($code) {
            $tool = new accesstoken();
            $token = $tool->getAccessToken();
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token='.$token.'&code='.$code;
            return curl::callWebServer($queryUrl, '', 'GET', 1 , 0);
        }
        
        /*
         * 添加新用户
         */
        public function createUser($data){
            $tool = new accesstoken();
            $token = $tool->getAccessToken('txl');
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token='.$token;
            return curl::callWebServer($queryUrl, $data, 'POST', 1 , 0);
        }
        
        
        /*
         * 更新用户
         */
        public function updateUser($data){
            $tool = new accesstoken();
            $token = $tool->getAccessToken('txl');
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token='.$token;
            return curl::callWebServer($queryUrl, $data, 'POST', 1 , 0);
        }
        
        
        /*
         * 删除用户
         */
        public function deleteUser($uid){
            $tool = new accesstoken();
            $token = $tool->getAccessToken('txl');
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token='.$token.'&userid='.$uid;
            return curl::callWebServer($queryUrl, '', 'GET', 1 , 0);
        }
        
        
        /*
         * 更新部门
         */
        public function updateDept($data) {
            $tool = new accesstoken();
            $token = $tool->getAccessToken('txl');
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/department/update?access_token='.$token;
            return curl::callWebServer($queryUrl, $data, 'POST', 1 , 0);
        }
        
        /*
         * 创建部门
         */
        public function createDept($data) {
            $tool = new accesstoken();
            $token = $tool->getAccessToken('txl');
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token='.$token;
            return curl::callWebServer($queryUrl, $data, 'POST', 1 , 0);
        }
        
        public function getDeptList($id) {
            $tool = new accesstoken();
            $token = $tool->getAccessToken('txl');
            $queryUrl = 'https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token='.$token.'&id='.$id;
            return curl::callWebServer($queryUrl, '', 'GET', 1 , 0);
        }
}   
?>